var express = require('express');
var router = express.Router();

const sql = require("../sql/sql");
const banner = require("../sql/banner");

/**
* @apiGroup 轮播图数据
* @api {get} /api/banner 获取轮播图数据
* @apiVersion 0.0.0
* @apiDescription 获取轮播图数据
* @apiSuccess {number} state 请求状态
* @apiSuccess {string} title 请求说明
* @apiSuccess {object} data 请求数据
* @apiSuccessExample {json} Success-Response:
* {
*    "state":200,
*    "title":"请求成功",
*    "data":[{},{},...]
* }
* @apiSampleRequest http://localhost:3000/api/banner
*/

// 获取所有轮播图图片
router.get('/', function(req, res, next) {
    sql.find(banner,{},{_id:0,__v:0}).then(data=>{
        res.send({
            state:200,
            title:"请求成功",
            data:data
        })
    })
});

module.exports = router;
